package pers.hl.module_main.admin.book

import pers.hl.lib_global.http.LibResponse
import pers.hl.lib_global.model.bean.Book
import pers.hl.lib_global.model.bean.Comment
import pers.hl.lib_global.model.bean.Reply
import pers.hl.lib_global.mvvm.BaseLibModel

class BookManageModel: BaseLibModel() {

    suspend fun getAllBooks(): LibResponse<List<Book>> {
        return libService.getAllBooks()
    }

    suspend fun deleteBooks(bookIds: List<Int>): LibResponse<*> {
        return libService.deleteBooks(bookIds)
    }

    suspend fun fetchComments(bookId: Int): LibResponse<List<Comment>> {
        return libService.getBookComments(bookId)
    }

    suspend fun fetchBookInfo(bookId: Int): LibResponse<Book> {
        return libService.getBookInfo(bookId)
    }

    suspend fun addComment(comment: Comment): LibResponse<*> {
        return libService.addComment(comment)
    }

    suspend fun deleteComment(cmtId: Int): LibResponse<*> {
        val ids = listOf(cmtId)
        return libService.deleteComment(ids)
    }

    suspend fun addReply(reply: Reply): LibResponse<*> {
        return libService.addReply(reply)
    }

    suspend fun fetchReplyList(cmtId: Int): LibResponse<List<Reply>> {
        return libService.fetchReplyListByCmtId(cmtId)
    }

    suspend fun collect(bookId: Int): LibResponse<*> {
        return libService.collect(bookId)
    }

    suspend fun unCollect(bookId: Int): LibResponse<*> {
        return libService.uncollect(bookId)
    }

    suspend fun borrowBook(bookId: Int): LibResponse<*> {
        return libService.borrow(bookId)
    }

}
